package com.lxb.staservice.controller;


import com.lxb.commonutils.R;
import com.lxb.staservice.client.UnceterClient;
import com.lxb.staservice.service.StatisticsDailyService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 网站统计日数据 前端控制器
 *
 * @author lixuebin
 * @since 2023-01-29
 */
@Api("网站统计日数据")
@RestController
@RequestMapping("/staservice/daily")
//@CrossOrigin
public class StatisticsDailyController {

    @Autowired
    private StatisticsDailyService staService;

    /**
     * 统计某一天注册人数
     *
     * @param day YYYY-mm-dd
     * @return
     */
    @PostMapping("/createStatisticsByDay/{day}")
    public R createStatisticsByDay(@PathVariable String day) {
        staService.createStatisticsByDay(day);
        return R.ok();
    }

    /**
     * 图表显示，返回数据
     *
     * @param type  查询数据类型
     * @param begin 开始日期
     * @param end   结束日期
     * @return
     */
    @GetMapping("showChart/{type}/{begin}/{end}")
    public R showChart(@PathVariable String type, @PathVariable String begin, @PathVariable String end) {
        Map<String, Object> map = staService.getChartData(begin, end, type);
        return R.ok().data(map);
    }
}

